from django.db import models


class ExecutionRecord(models.Model):
    server_ids = models.JSONField(verbose_name="执行机器")
    command = models.CharField(max_length=100, verbose_name="执行命令")
    status_choice = (
        (1, "成功"),
        (2, "异常"),
    )
    status = models.IntegerField(choices=status_choice, default=1, verbose_name="状态")
    user = models.CharField(max_length=20, verbose_name="执行用户")
    note = models.TextField(blank=True, null=True, verbose_name="执行描述")
    result = models.TextField(blank=True, null=True, verbose_name="执行结果")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        db_table = "batch_executionrecord"
        verbose_name_plural = "执行记录"
        ordering = ('-id',)

    def __str__(self):
        return self.user



